﻿using System;
using System.Collections.Generic;
using System.Xml;
using Autodesk.Revit.DB;

namespace HYOpeningCommon.OpeningProfile
{
	public abstract class OpeningProfileBase
	{
		public virtual string GetCutSize(bool bIsFeet)
		{
			return null;
		}

		public virtual string GetOpeningSize(bool bIsFeet)
		{
			return null;
		}

		public Plane GetProfilePlane()
		{
			return null;
		}

		public virtual Outline GetSectionOutline3D()
		{
			return null;
		}

		public virtual bool Export2XmlNode(XmlElement xmlNode)
		{
			bool result;
			try
			{
				xmlNode.SetAttribute("OpeningProfileName", base.GetType().Name);
				xmlNode.SetAttribute("PtX", this.m_position.X.ToString());
				xmlNode.SetAttribute("PtY", this.m_position.Y.ToString());
				xmlNode.SetAttribute("PtZ", this.m_position.Z.ToString());
				xmlNode.SetAttribute("DirCutX", this.m_directionCutObj.X.ToString());
				xmlNode.SetAttribute("DirCutY", this.m_directionCutObj.Y.ToString());
				xmlNode.SetAttribute("DirCutZ", this.m_directionCutObj.Z.ToString());
				xmlNode.SetAttribute("DirProfX", this.m_directionProfile.X.ToString());
				xmlNode.SetAttribute("DirProfY", this.m_directionProfile.Y.ToString());
				xmlNode.SetAttribute("DirProfZ", this.m_directionProfile.Z.ToString());
				xmlNode.SetAttribute("ExtendDist", this.m_dExtendDist.ToString());
				xmlNode.SetAttribute("PenetrationThickness", this.m_dPenetrationThickness.ToString());
				result = true;
			}
			catch
			{
				result = false;
			}
			return result;
		}

		public virtual bool ImportByXmlNode(XmlNode xmlNode)
		{
			try
			{
				double num = Convert.ToDouble(xmlNode.Attributes["PtX"].Value);
				double num2 = Convert.ToDouble(xmlNode.Attributes["PtY"].Value);
				double num3 = Convert.ToDouble(xmlNode.Attributes["PtZ"].Value);
				this.m_position = new XYZ(num, num2, num3);
				double num4 = Convert.ToDouble(xmlNode.Attributes["DirCutX"].Value);
				double num5 = Convert.ToDouble(xmlNode.Attributes["DirCutY"].Value);
				double num6 = Convert.ToDouble(xmlNode.Attributes["DirCutZ"].Value);
				this.m_directionCutObj = new XYZ(num4, num5, num6);
				double num7 = Convert.ToDouble(xmlNode.Attributes["DirProfX"].Value);
				double num8 = Convert.ToDouble(xmlNode.Attributes["DirProfY"].Value);
				double num9 = Convert.ToDouble(xmlNode.Attributes["DirProfZ"].Value);
				this.m_directionProfile = new XYZ(num7, num8, num9);
				this.m_dExtendDist = Convert.ToDouble(xmlNode.Attributes["ExtendDist"].Value);
				this.m_dPenetrationThickness = Convert.ToDouble(xmlNode.Attributes["PenetrationThickness"].Value);
			}
			catch
			{
				return false;
			}
			return true;
		}

		public virtual void GetProfileOutLineOnXOY(ref List<XYZ> lstPreviewPt, bool isAddExtend)
		{
		}

		public XYZ m_position;

		public XYZ m_directionCutObj;

		public XYZ m_directionProfile;

		public double m_dExtendDist;

		public double m_dTolerance;

		public double m_dPenetrationThickness;
	}
}
